package org.example.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
public class AController {

    @GetMapping("/gotoPage")
    public String gotoPage(HttpServletRequest request) {
        request.setAttribute("a", 1);
        request.setAttribute("b", 1);
        return "forward:/success"; //转发请求
    }

    @ResponseBody
    @GetMapping("/success")
    public String success(@RequestAttribute("a") Integer a) {
        return "成功" + a;
    }
}
